package com.itheima.controller;

import com.itheima.entity.PageBean;
import com.itheima.entity.User;
import com.itheima.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("address")
public class AddressController {
    @Autowired
    private HttpSession session;

    @Autowired
    private AddressService addressService;

    @RequestMapping("find")
    public PageBean find(@RequestBody Map<String,Object> params){
        User user = (User) session.getAttribute("user");
        int current = (int)params.get("current");
        int size = (int) params.get("size");
        return addressService.findAddress(current,size,user.getUid());
    }
}
